<?php

Yii::import("xupload.models.XUploadForm");

class RestoreController extends Controller {

    public function actionRkakl() {

        Yii::import("xupload.models.XUploadForm");
        $model = new XUploadForm;
        $this->render('rkakl', array('model' => $model,));
    }
	
	 public function actionSakpa() {

        Yii::import("xupload.models.XUploadForm");
        $model = new XUploadForm;
        $this->render('sakpa', array('model' => $model,));
    }

    public function actionUpload() {
        /*return array(
            'upload' => array(
                'class' => 'xupload.actions.XUploadAction',
                'path' => Yii::app()->getBasePath() . "/../temp",
                "publicPath" => Yii::app()->getBaseUrl() . "/temp"),
            );*/
        Yii::import("xupload.models.XUploadForm");
        $path = Yii::app()->getBasePath() . "/../temp/";
        $publicPath = Yii::app()->getBaseUrl() . "/temp";
        header( 'Vary: Accept' );
    if( isset( $_SERVER['HTTP_ACCEPT'] ) 
        && (strpos( $_SERVER['HTTP_ACCEPT'], 'application/json' ) !== false) ) {
        header( 'Content-type: application/json' );
    } else {
        header( 'Content-type: text/plain' );
    }
 
    //Here we check if we are deleting and uploaded file
    if( isset( $_GET["_method"] ) ) {
        if( $_GET["_method"] == "delete" ) {
            if( $_GET["file"][0] !== '.' ) {
                $file = $path.$_GET["file"];
                if( is_file( $file ) ) {
                    unlink( $file );
                }
            }
            echo json_encode( true );
        }
    } else {
        $model = new XUploadForm;
        $model->file = CUploadedFile::getInstance( $model, 'file' );
        //We check that the file was successfully uploaded
        if( $model->file !== null ) {
            //Grab some data
            $model->mime_type = $model->file->getType( );
            $model->size = $model->file->getSize( );
            $model->name = $model->file->getName( );
            //(optional) Generate a random name for our file
            $filename = $model->name;
            //$filename .= ".".$model->file->getExtensionName( );
            if( $model->validate( ) ) {
                //Move our file to our temporary dir
                $model->file->saveAs( $path.$filename );
                chmod( $path.$filename, 0777 );
                $filenya=$filename;
                $upload_path=$path;
                exec(getenv("DOCUMENT_ROOT") . '/rkakl-thinkfrogs/7za x ' . $path . $filenya);
                unlink($path . $filenya);
                $dir = $path;
                $dh = opendir($dir);
                $files = array();
                while (($file = readdir($dh)) !== false) {
                    $files[] = $file;
                }
                unset($files[0]);
                unset($files[1]);

                foreach ($files as $key => $fileName) {

                    set_time_limit(0);
                    $restore_path = str_replace("/", "\\", $path);
                    $conn = new COM("ADODB.Connection");
                    $conn->Open('Provider=VFPOLEDB.1;Data Source="' . $restore_path . $fileName . '";Password="";Collating Sequence=MACHINE');
                    switch (substr($fileName, 0, 2)) {
                        case "AK":
                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    "THANG" => '' . $rs->Fields['THANG'] . '',
                                    "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                                    "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                                    "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                                    "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                                    "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                                    "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                                    "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                                    "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                                    "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                                    "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                                    "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                                    "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                                    "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                                    "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                                    "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                                    "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                                    "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                                    "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                                    "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                                    "PROSENPHLN" => '' . $rs->Fields['PROSENPHLN'] . '',
                                    "PROSENRKP" => '' . $rs->Fields['PROSENRKP'] . '',
                                    "PROSENRMP" => '' . $rs->Fields['PROSENRMP'] . '',
                                    "KPPNRKP" => '' . $rs->Fields['KPPNRKP'] . '',
                                    "KPPNRMP" => '' . $rs->Fields['KPPNRMP'] . '',
                                    "KPPNPHLN" => '' . $rs->Fields['KPPNPHLN'] . '',
                                    "REGDAM" => '' . $rs->Fields['REGDAM'] . '',
                                    "KDLUNCURAN" => '' . $rs->Fields['KDLUNCURAN'] . '',
                                    "KDIB" => '' . $rs->Fields['KDIB'] . '',
                                        //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DAkun;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->KDKMPNEN = $r['KDKMPNEN'];
                                $model->KDSKMPNEN = $r['KDSKMPNEN'];
                                $model->KDAKUN = $r['KDAKUN'];
                                $model->KDKPPN = $r['KDKPPN'];
                                $model->KDBEBAN = $r['KDBEBAN'];
                                $model->KDJNSBAN = $r['KDJNSBAN'];
                                $model->KDCTARIK = $r['KDCTARIK'];
                                $model->REGISTER = $r['REGISTER'];
                                $model->CARAHITUNG = $r['CARAHITUNG'];
                                $model->PROSENPHLN = $r['PROSENPHLN'];
                                $model->PROSENRKP = $r['PROSENRKP'];
                                $model->PROSENRMP = $r['PROSENRMP'];
                                $model->KPPNRKP = $r['KPPNRKP'];
                                $model->KPPNRMP = $r['KPPNRMP'];
                                $model->KPPNPHLN = $r['KPPNPHLN'];
                                $model->REGDAM = $r['REGDAM'];
                                $model->KDLUNCURAN = $r['KDLUNCURAN'];
                                $model->KDIB = $r['KDIB'];
                                //  $model->_NullFlags=$r['_NullFlags'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;
                        case "BL":
                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    "THANG" => '' . $rs->Fields['THANG'] . '',
                                    "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                                    "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                                    "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                                    "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                                    "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                                    "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                                    "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                                    "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                                    "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                                    "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                                    "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                                    "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                                    "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                                    "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                                    "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                                    "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                                    "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                                    "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                                    "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                                    "KDBLOKIR" => '' . $rs->Fields['KDBLOKIR'] . '',
                                    "URAIBLOKIR" => '' . $rs->Fields['URAIBLOKIR'] . '',
                                    "KDIB" => '' . $rs->Fields['KDIB'] . '',
                                        //"_NullFlags"=>''.$rs->Fields[''].''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DBlokir;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->KDKMPNEN = $r['KDKMPNEN'];
                                $model->KDSKMPNEN = $r['KDSKMPNEN'];
                                $model->KDAKUN = $r['KDAKUN'];
                                $model->KDKPPN = $r['KDKPPN'];
                                $model->KDBEBAN = $r['KDBEBAN'];
                                $model->KDJNSBAN = $r['KDJNSBAN'];
                                $model->KDCTARIK = $r['KDCTARIK'];
                                $model->REGISTER = $r['REGISTER'];
                                $model->CARAHITUNG = $r['CARAHITUNG'];
                                $model->KDBLOKIR = $r['KDBLOKIR'];
                                $model->URAIBLOKIR = $r['URAIBLOKIR'];
                                $model->KDIB = $r['KDIB'];
                                //   $model->_NullFlags=$r['_NullFlags'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;
                        case "CT":
                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    "THANG" => '' . $rs->Fields['THANG'] . '',
                                    "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                                    "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                                    "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                                    "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                                    "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                                    "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                                    "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                                    "KDIB" => '' . $rs->Fields['KDIB'] . '',
                                    "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                                    "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                                    "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                                    "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                                    "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                                    "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                                    "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                                    "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                                    "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                                    "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                                    "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                                    "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                                    "KET" => '' . $rs->Fields['KET'] . '',
                                    "KET2" => '' . $rs->Fields['KET2'] . '',
                                        // "_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DCttakun;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDIB = $r['KDIB'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->KDKMPNEN = $r['KDKMPNEN'];
                                $model->KDSKMPNEN = $r['KDSKMPNEN'];
                                $model->KDAKUN = $r['KDAKUN'];
                                $model->KDKPPN = $r['KDKPPN'];
                                $model->KDBEBAN = $r['KDBEBAN'];
                                $model->KDJNSBAN = $r['KDJNSBAN'];
                                $model->KDCTARIK = $r['KDCTARIK'];
                                $model->REGISTER = $r['REGISTER'];
                                $model->CARAHITUNG = $r['CARAHITUNG'];
                                $model->KET = $r['KET'];
                                $model->KET2 = $r['KET2'];
                                //	   $model->_NullFlags=$r['_NullFlags'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;
                        case "IT":
                            $restore_path = str_replace("/", "\\", $upload_path);
                            $conn = new COM("ADODB.Connection");
                            $conn->Open('Provider=VFPOLEDB.1;Data Source="' . $restore_path . $fileName . '";Password="";Collating Sequence=MACHINE');
                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    "THANG" => '' . $rs->Fields['THANG'] . '',
                                    "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                                    "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                                    "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                                    "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                                    "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                                    "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                                    "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                                    "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                                    "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                                    "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                                    "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                                    "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                                    "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                                    "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                                    "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                                    "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                                    "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                                    "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                                    "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                                    "HEADER1" => '' . $rs->Fields['HEADER1'] . '',
                                    "HEADER2" => '' . $rs->Fields['HEADER2'] . '',
                                    "KDHEADER" => '' . $rs->Fields['KDHEADER'] . '',
                                    "NOITEM" => '' . $rs->Fields['NOITEM'] . '',
                                    "NMITEM" => '' . $rs->Fields['NMITEM'] . '',
                                    "VOL1" => '' . $rs->Fields['VOL1'] . '',
                                    "SAT1" => '' . $rs->Fields['SAT1'] . '',
                                    "VOL2" => '' . $rs->Fields['VOL2'] . '',
                                    "SAT2" => '' . $rs->Fields['SAT2'] . '',
                                    "VOL3" => '' . $rs->Fields['VOL3'] . '',
                                    "SAT3" => '' . $rs->Fields['SAT3'] . '',
                                    "VOL4" => '' . $rs->Fields['VOL4'] . '',
                                    "SAT4" => '' . $rs->Fields['SAT4'] . '',
                                    "VOLKEG" => '' . $rs->Fields['VOLKEG'] . '',
                                    "SATKEG" => '' . $rs->Fields['SATKEG'] . '',
                                    "HARGASAT" => '' . $rs->Fields['HARGASAT'] . '',
                                    "JUMLAH" => '' . $rs->Fields['JUMLAH'] . '',
                                    "PAGUPHLN" => '' . $rs->Fields['PAGUPHLN'] . '',
                                    "PAGURMP" => '' . $rs->Fields['PAGURMP'] . '',
                                    "PAGURKP" => '' . $rs->Fields['PAGURKP'] . '',
                                    "KDBLOKIR" => '' . $rs->Fields['KDBLOKIR'] . '',
                                    "BLOKIRPHLN" => '' . $rs->Fields['BLOKIRPHLN'] . '',
                                    "BLOKIRRMP" => '' . $rs->Fields['BLOKIRRMP'] . '',
                                    "BLOKIRRKP" => '' . $rs->Fields['BLOKIRRKP'] . '',
                                    "RPHBLOKIR" => '' . $rs->Fields['RPHBLOKIR'] . '',
                                    "KDCOPY" => '' . $rs->Fields['KDCOPY'] . '',
                                    "KDABT" => '' . $rs->Fields['KDABT'] . '',
                                    "KDSBU" => '' . $rs->Fields['KDSBU'] . '',
                                    "VOLSBK" => '' . $rs->Fields['VOLSBK'] . '',
                                    "VOLRKAKL" => '' . $rs->Fields['VOLRKAKL'] . '',
                                    "BLNKONTRAK" => '' . $rs->Fields['BLNKONTRAK'] . '',
                                    "NOKONTRAK" => '' . $rs->Fields['NOKONTRAK'] . '',
                                    "TGKONTRAK" => '' . $rs->Fields['TGKONTRAK'] . '',
                                    "NILKONTRAK" => '' . $rs->Fields['NILKONTRAK'] . '',
                                    "JANUARI" => '' . $rs->Fields['JANUARI'] . '',
                                    "PEBRUARI" => '' . $rs->Fields['PEBRUARI'] . '',
                                    "MARET" => '' . $rs->Fields['MARET'] . '',
                                    "APRIL" => '' . $rs->Fields['APRIL'] . '',
                                    "MEI" => '' . $rs->Fields['MEI'] . '',
                                    "JUNI" => '' . $rs->Fields['JUNI'] . '',
                                    "JULI" => '' . $rs->Fields['JULI'] . '',
                                    "AGUSTUS" => '' . $rs->Fields['AGUSTUS'] . '',
                                    "SEPTEMBER" => '' . $rs->Fields['SEPTEMBER'] . '',
                                    "OKTOBER" => '' . $rs->Fields['OKTOBER'] . '',
                                    "NOPEMBER" => '' . $rs->Fields['NOPEMBER'] . '',
                                    "DESEMBER" => '' . $rs->Fields['DESEMBER'] . '',
                                    "JMLTUNDA" => '' . $rs->Fields['JMLTUNDA'] . '',
                                    "KDLUNCURAN" => '' . $rs->Fields['KDLUNCURAN'] . '',
                                    "JMLABT" => '' . $rs->Fields['JMLABT'] . '',
                                    "NOREV" => '' . $rs->Fields['NOREV'] . '',
                                    "KDUBAH" => '' . $rs->Fields['KDUBAH'] . '',
                                    "KURS" => '' . $rs->Fields['KURS'] . '',
                                    "INDEXKPJM" => '' . $rs->Fields['INDEXKPJM'] . '',
                                    "KDIB" => '' . $rs->Fields['KDIB'] . '',
                                        //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DItem;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->KDKMPNEN = $r['KDKMPNEN'];
                                $model->KDSKMPNEN = $r['KDSKMPNEN'];
                                $model->KDAKUN = $r['KDAKUN'];
                                $model->KDKPPN = $r['KDKPPN'];
                                $model->KDBEBAN = $r['KDBEBAN'];
                                $model->KDJNSBAN = $r['KDJNSBAN'];
                                $model->KDCTARIK = $r['KDCTARIK'];
                                $model->REGISTER = $r['REGISTER'];
                                $model->CARAHITUNG = $r['CARAHITUNG'];
                                $model->HEADER1 = $r['HEADER1'];
                                $model->HEADER2 = $r['HEADER2'];
                                $model->KDHEADER = $r['KDHEADER'];
                                $model->NOITEM = $r['NOITEM'];
                                $model->NMITEM = $r['NMITEM'];
                                $model->VOL1 = $r['VOL1'];
                                $model->SAT1 = $r['SAT1'];
                                $model->VOL2 = $r['VOL2'];
                                $model->SAT2 = $r['SAT2'];
                                $model->VOL3 = $r['VOL3'];
                                $model->SAT3 = $r['SAT3'];
                                $model->VOL4 = $r['VOL4'];
                                $model->SAT4 = $r['SAT4'];
                                $model->VOLKEG = $r['VOLKEG'];
                                $model->SATKEG = $r['SATKEG'];
                                $model->HARGASAT = $r['HARGASAT'];
                                $model->JUMLAH = $r['JUMLAH'];
                                $model->PAGUPHLN = $r['PAGUPHLN'];
                                $model->PAGURMP = $r['PAGURMP'];
                                $model->PAGURKP = $r['PAGURKP'];
                                $model->KDBLOKIR = $r['KDBLOKIR'];
                                $model->BLOKIRPHLN = $r['BLOKIRPHLN'];
                                $model->BLOKIRRMP = $r['BLOKIRRMP'];
                                $model->BLOKIRRKP = $r['BLOKIRRKP'];
                                $model->RPHBLOKIR = $r['RPHBLOKIR'];
                                $model->KDCOPY = $r['KDCOPY'];
                                $model->KDABT = $r['KDABT'];
                                $model->KDSBU = $r['KDSBU'];
                                $model->VOLSBK = $r['VOLSBK'];
                                $model->VOLRKAKL = $r['VOLRKAKL'];
                                $model->BLNKONTRAK = $r['BLNKONTRAK'];
                                $model->NOKONTRAK = $r['NOKONTRAK'];
                                $model->TGKONTRAK = $r['TGKONTRAK'];
                                $model->NILKONTRAK = $r['NILKONTRAK'];
                                $model->JANUARI = $r['JANUARI'];
                                $model->PEBRUARI = $r['PEBRUARI'];
                                $model->MARET = $r['MARET'];
                                $model->APRIL = $r['APRIL'];
                                $model->MEI = $r['MEI'];
                                $model->JUNI = $r['JUNI'];
                                $model->JULI = $r['JULI'];
                                $model->AGUSTUS = $r['AGUSTUS'];
                                $model->SEPTEMBER = $r['SEPTEMBER'];
                                $model->OKTOBER = $r['OKTOBER'];
                                $model->NOPEMBER = $r['NOPEMBER'];
                                $model->DESEMBER = $r['DESEMBER'];
                                $model->JMLTUNDA = $r['JMLTUNDA'];
                                $model->KDLUNCURAN = $r['KDLUNCURAN'];
                                $model->JMLABT = $r['JMLABT'];
                                $model->NOREV = $r['NOREV'];
                                $model->KDUBAH = $r['KDUBAH'];
                                $model->KURS = $r['KURS'];
                                $model->INDEXKPJM = $r['INDEXKPJM'];
                                $model->KDIB = $r['KDIB'];
                                //	   $model->_NullFlags=$r['_NullFlags'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;
                        case "KA":
                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    "THANG" => '' . $rs->Fields['THANG'] . '',
                                    "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                                    "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                                    "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                                    "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                                    "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                                    "KPA" => '' . $rs->Fields['KPA'] . '',
                                    "BENDAHARA" => '' . $rs->Fields['BENDAHARA'] . '',
                                    "PPSPM" => '' . $rs->Fields['PPSPM'] . '',
                                    "TEST" => '' . $rs->Fields['TEST'] . '',
                                    "STATUSBLU" => '' . $rs->Fields['STATUSBLU'] . '',
                                    "PPLPNBP" => '' . $rs->Fields['PPLPNBP'] . '',
                                    "ESAWK" => '' . $rs->Fields['ESAWK'] . '',
                                    "ESAWKGUNA" => '' . $rs->Fields['ESAWKGUNA'] . '',
                                    "ESAKK" => '' . $rs->Fields['ESAKK'] . '',
                                    "AMBANGBATS" => '' . $rs->Fields['AMBANGBATS'] . '',
                                    "NPWP" => '' . $rs->Fields['NPWP'] . '',
                                    "NODIPA" => '' . $rs->Fields['NODIPA'] . '',
                                    "NOSPRKAKL" => '' . $rs->Fields['NOSPRKAKL'] . '',
                                    "THSPRKAKL" => '' . $rs->Fields['THSPRKAKL'] . '',
                                    "DASARDIPA" => '' . $rs->Fields['DASARDIPA'] . '',
                                    "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . ''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DKpa;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KPA = $r['KPA'];
                                $model->BENDAHARA = $r['BENDAHARA'];
                                $model->PPSPM = $r['PPSPM'];
                                $model->TEST = $r['TEST'];
                                $model->STATUSBLU = $r['STATUSBLU'];
                                $model->PPLPNBP = $r['PPLPNBP'];
                                $model->ESAWK = $r['ESAWK'];
                                $model->ESAWKGUNA = $r['ESAWKGUNA'];
                                $model->ESAKK = $r['ESAKK'];
                                $model->AMBANGBATS = $r['AMBANGBATS'];
                                $model->NPWP = $r['NPWP'];
                                $model->NODIPA = $r['NODIPA'];
                                $model->NOSPRKAKL = $r['NOSPRKAKL'];
                                $model->THSPRKAKL = $r['THSPRKAKL'];
                                $model->DASARDIPA = $r['DASARDIPA'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;
                        case "KM":
                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    "THANG" => '' . $rs->Fields['THANG'] . '',
                                    "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                                    "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                                    "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                                    "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                                    "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                                    "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                                    "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                                    "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                                    "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                                    "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                                    "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                                    "KDBIAYA" => '' . $rs->Fields['KDBIAYA'] . '',
                                    "KDSBIAYA" => '' . $rs->Fields['KDSBIAYA'] . '',
                                    "URKMPNEN" => '' . $rs->Fields['URKMPNEN'] . '',
                                    "KDTEMA" => '' . $rs->Fields['KDTEMA'] . '',
                                    "RPHPLS1" => '' . $rs->Fields['RPHPLS1'] . '',
                                    "RPHPLS2" => '' . $rs->Fields['RPHPLS2'] . '',
                                    "RPHPLS3" => '' . $rs->Fields['RPHPLS3'] . '',
                                    "RPHMIN1" => '' . $rs->Fields['RPHMIN1'] . '',
                                    "THANGAWAL" => '' . $rs->Fields['THANGAWAL'] . '',
                                    "THANGAKHIR" => '' . $rs->Fields['THANGAKHIR'] . '',
                                    "INDEKSKALI" => '' . $rs->Fields['INDEKSKALI'] . '',
                                    "KDIB" => '' . $rs->Fields['KDIB'] . '',
                                    "INDEKSOUT" => '' . $rs->Fields['INDEKSOUT'] . '',
                                        //"_NullFlags"=>''.$rs->Fields['_NullFlags'].'',
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DKmpnen;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->KDKMPNEN = $r['KDKMPNEN'];
                                $model->KDBIAYA = $r['KDBIAYA'];
                                $model->KDSBIAYA = $r['KDSBIAYA'];
                                $model->URKMPNEN = $r['URKMPNEN'];
                                $model->KDTEMA = $r['KDTEMA'];
                                $model->RPHPLS1 = $r['RPHPLS1'];
                                $model->RPHPLS2 = $r['RPHPLS2'];
                                $model->RPHPLS3 = $r['RPHPLS3'];
                                $model->RPHMIN1 = $r['RPHMIN1'];
                                $model->THANGAWAL = $r['THANGAWAL'];
                                $model->THANGAKHIR = $r['THANGAKHIR'];
                                $model->INDEKSKALI = $r['INDEKSKALI'];
                                $model->KDIB = $r['KDIB'];
                                $model->INDEKSOUT = $r['INDEKSOUT'];
                                //	   $model->_NullFlags=$r['_NullFlags'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "OU":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                                    'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                                    'KDOUTPUT' => '' . $rs->Fields['KDOUTPUT'] . '',
                                    'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                                    'KDKABKOTA' => '' . $rs->Fields['KDKABKOTA'] . '',
                                    'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                                    'VOLMIN1' => '' . $rs->Fields['VOLMIN1'] . '',
                                    'VOL' => '' . $rs->Fields['VOL'] . '',
                                    'VOLPLS1' => '' . $rs->Fields['VOLPLS1'] . '',
                                    'VOLPLS2' => '' . $rs->Fields['VOLPLS2'] . '',
                                    'VOLPLS3' => '' . $rs->Fields['VOLPLS3'] . '',
                                    'RPHMIN1' => '' . $rs->Fields['RPHMIN1'] . '',
                                    'RPHPLS1' => '' . $rs->Fields['RPHPLS1'] . '',
                                    'RPHPLS2' => '' . $rs->Fields['RPHPLS2'] . '',
                                    'RPHPLS3' => '' . $rs->Fields['RPHPLS3'] . '',
                                    'SBKKET' => '' . $rs->Fields['SBKKET'] . '',
                                    'SBKMIN1' => '' . $rs->Fields['SBKMIN1'] . '',
                                    'KDSB' => '' . $rs->Fields['KDSB'] . '',
                                    'KDJOUTPUT' => '' . $rs->Fields['KDJOUTPUT'] . '',
                                    'THANGAWAL' => '' . $rs->Fields['THANGAWAL'] . '',
                                    'THANGAKHIR' => '' . $rs->Fields['THANGAKHIR'] . '',
                                    'KDTEMA' => '' . $rs->Fields['KDTEMA'] . '',
                                    'KDIB' => '' . $rs->Fields['KDIB'] . '',
                                    'KDAUTO' => '' . $rs->Fields['KDAUTO'] . ''
                                        //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DOutput;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->VOLMIN1 = $r['VOLMIN1'];
                                $model->VOL = $r['VOL'];
                                $model->VOLPLS1 = $r['VOLPLS1'];
                                $model->VOLPLS2 = $r['VOLPLS2'];
                                $model->VOLPLS3 = $r['VOLPLS3'];
                                $model->RPHMIN1 = $r['RPHMIN1'];
                                $model->RPHPLS1 = $r['RPHPLS1'];
                                $model->RPHPLS3 = $r['RPHPLS3'];
                                $model->SBKKET = $r['SBKKET'];
                                $model->SBKMIN1 = $r['SBKMIN1'];
                                $model->KDSB = $r['KDSB'];
                                $model->KDJOUTPUT = $r['KDJOUTPUT'];
                                $model->THANGAWAL = $r['THANGAWAL'];
                                $model->THANGAKHIR = $r['THANGAKHIR'];
                                $model->KDTEMA = $r['KDTEMA'];
                                $model->KDIB = $r['KDIB'];
                                $model->KDAUTO = $r['KDAUTO'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "PD":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                                    'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                                    'KDAKUN' => '' . $rs->Fields['KDAKUN'] . '',
                                    'KDPNBPF' => '' . $rs->Fields['KDPNBPF'] . '',
                                    'RPHMIN1' => '' . $rs->Fields['RPHMIN1'] . '',
                                    'RPHPDPT' => '' . $rs->Fields['RPHPDPT'] . '',
                                    'RPHPLS1' => '' . $rs->Fields['RPHPLS1'] . '',
                                    'RPHPLS2' => '' . $rs->Fields['RPHPLS2'] . '',
                                    'RPHPLS3' => '' . $rs->Fields['RPHPLS3'] . '',
                                        //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DPdpt;
                                $model->THANG = $r['THANG'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDAKUN = $r['KDAKUN'];
                                $model->KDPNBPF = $r['KDPNBPF'];
                                $model->RPHMIN1 = $r['RPHMIN1'];
                                $model->RPHPDPT = $r['RPHPDPT'];
                                $model->RPHPLS1 = $r['RPHPLS1'];
                                $model->RPHPLS2 = $r['RPHPLS2'];
                                $model->RPHPLS3 = $r['RPHPLS3'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "SM":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                                    'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                                    'KDOUTPUT' => '' . $rs->Fields['KDOUTPUT'] . '',
                                    'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                                    'KDKABKOTA' => '' . $rs->Fields['KDKABKOTA'] . '',
                                    'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                                    'KDSOUTPUT' => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    'KDKMPNEN' => '' . $rs->Fields['KDKMPNEN'] . '',
                                    'KDSKMPNEN' => '' . $rs->Fields['KDSKMPNEN'] . '',
                                    'URSKMPNEN' => '' . $rs->Fields['URSKMPNEN'] . '',
                                    'KDIB' => '' . $rs->Fields['KDIB'] . '',
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DSkmpnen;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->KDKMPNEN = $r['KDKMPNEN'];
                                $model->KDSKMPNEN = $r['KDSKMPNEN'];
                                $model->URSKMPNEN = $r['URSKMPNEN'];
                                $model->KDIB = $r['KDIB'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "SO":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                                    'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                                    'KDOUTPUT' => '' . $rs->Fields['KDOUTPUT'] . '',
                                    'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                                    'KDKABKOTA' => '' . $rs->Fields['KDKABKOTA'] . '',
                                    'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                                    'KDSOUTPUT' => '' . $rs->Fields['KDSOUTPUT'] . '',
                                    'URSOUTPUT' => '' . $rs->Fields['URSOUTPUT'] . '',
                                    'SBMKVOL' => '' . $rs->Fields['SBMKVOL'] . '',
                                    'SBMKSAT' => '' . $rs->Fields['SBMKSAT'] . '',
                                    'SBMKMIN1' => '' . $rs->Fields['SBMKMIN1'] . '',
                                    'SBMKKET' => '' . $rs->Fields['SBMKKET'] . '',
                                    'KDSB' => '' . $rs->Fields['KDSB'] . '',
                                    'VOLSOUT' => '' . $rs->Fields['VOLSOUT'] . '',
                                    'KDIB' => '' . $rs->Fields['KDIB'] . '',
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DSoutput;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->KDOUTPUT = $r['KDOUTPUT'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->KDKABKOTA = $r['KDKABKOTA'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDSOUTPUT = $r['KDSOUTPUT'];
                                $model->URSOUTPUT = $r['URSOUTPUT'];
                                $model->SBMKVOL = $r['SBMKVOL'];
                                $model->SBMKSAT = $r['SBMKSAT'];
                                $model->SBMKMIN1 = $r['SBMKMIN1'];
                                $model->SBMKKET = $r['SBMKKET'];
                                $model->KDSB = $r['KDSB'];
                                $model->VOLSOUT = $r['VOLSOUT'];
                                $model->KDIB = $r['KDIB'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "TR":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                                    'KDFUNGSI' => '' . $rs->Fields['KDFUNGSI'] . '',
                                    'KDSFUNG' => '' . $rs->Fields['KDSFUNG'] . '',
                                    'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                                    'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                                    'RPHPAGU' => '' . $rs->Fields['RPHPAGU'] . '',
                                    'KDTRKTRM' => '' . $rs->Fields['KDTRKTRM'] . '',
                                    'JNSBELANJA' => '' . $rs->Fields['JNSBELANJA'] . '',
                                    'JML01' => '' . $rs->Fields['JML01'] . '',
                                    'JML02' => '' . $rs->Fields['JML02'] . '',
                                    'JML03' => '' . $rs->Fields['JML03'] . '',
                                    'JML04' => '' . $rs->Fields['JML04'] . '',
                                    'JML05' => '' . $rs->Fields['JML05'] . '',
                                    'JML06' => '' . $rs->Fields['JML06'] . '',
                                    'JML07' => '' . $rs->Fields['JML07'] . '',
                                    'JML08' => '' . $rs->Fields['JML08'] . '',
                                    'JML09' => '' . $rs->Fields['JML09'] . '',
                                    'JML10' => '' . $rs->Fields['JML10'] . '',
                                    'JML11' => '' . $rs->Fields['JML11'] . '',
                                    'JML12' => '' . $rs->Fields['JML12'] . '',
                                    'PERSEN01' => '' . $rs->Fields['PERSEN01'] . '',
                                    'PERSEN02' => '' . $rs->Fields['PERSEN02'] . '',
                                    'PERSEN03' => '' . $rs->Fields['PERSEN03'] . '',
                                    'PERSEN04' => '' . $rs->Fields['PERSEN04'] . '',
                                    'PERSEN05' => '' . $rs->Fields['PERSEN05'] . '',
                                    'PERSEN06' => '' . $rs->Fields['PERSEN06'] . '',
                                    'PERSEN07' => '' . $rs->Fields['PERSEN07'] . '',
                                    'PERSEN08' => '' . $rs->Fields['PERSEN08'] . '',
                                    'PERSEN09' => '' . $rs->Fields['PERSEN09'] . '',
                                    'PERSEN10' => '' . $rs->Fields['PERSEN10'] . '',
                                    'PERSEN11' => '' . $rs->Fields['PERSEN11'] . '',
                                    'PERSEN12' => '' . $rs->Fields['PERSEN12'] . '',
                                    'CHK01' => '' . $rs->Fields['CHK01'] . '',
                                    'CHK02' => '' . $rs->Fields['CHK02'] . '',
                                    'CHK03' => '' . $rs->Fields['CHK03'] . '',
                                    'CHK04' => '' . $rs->Fields['CHK04'] . '',
                                    'CHK05' => '' . $rs->Fields['CHK05'] . '',
                                    'CHK06' => '' . $rs->Fields['CHK06'] . '',
                                    'CHK07' => '' . $rs->Fields['CHK07'] . '',
                                    'CHK08' => '' . $rs->Fields['CHK08'] . '',
                                    'CHK09' => '' . $rs->Fields['CHK09'] . '',
                                    'CHK10' => '' . $rs->Fields['CHK10'] . '',
                                    'CHK11' => '' . $rs->Fields['CHK11'] . '',
                                    'CHK12' => '' . $rs->Fields['CHK12'] . '',
                                    'CHKJMLTRK' => '' . $rs->Fields['CHKJMLTRK'] . '',
                                    'CHKPERSEN' => '' . $rs->Fields['CHKPERSEN'] . '',
                                    'CHKRATA2' => '' . $rs->Fields['CHKRATA2'] . '',
                                    'CHKRATA2GJ' => '' . $rs->Fields['CHKRATA2GJ'] . '',
                                    'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DTrktrm;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->KDFUNGSI = $r['KDFUNGSI'];
                                $model->KDSFUNG = $r['KDSFUNG'];
                                $model->KDPROGRAM = $r['KDPROGRAM'];
                                $model->KDGIAT = $r['KDGIAT'];
                                $model->RPHPAGU = $r['RPHPAGU'];
                                $model->KDTRKTRM = $r['KDTRKTRM'];
                                $model->JNSBELANJA = $r['JNSBELANJA'];
                                $model->JML01 = $r['JML01'];
                                $model->JML02 = $r['JML02'];
                                $model->JML03 = $r['JML03'];
                                $model->JML04 = $r['JML04'];
                                $model->JML05 = $r['JML05'];
                                $model->JML06 = $r['JML06'];
                                $model->JML07 = $r['JML07'];
                                $model->JML08 = $r['JML08'];
                                $model->JML09 = $r['JML09'];
                                $model->JML10 = $r['JML10'];
                                $model->JML11 = $r['JML11'];
                                $model->JML12 = $r['JML12'];
                                $model->CHK01 = $r['CHK01'];
                                $model->CHK02 = $r['CHK02'];
                                $model->CHK03 = $r['CHK03'];
                                $model->CHK04 = $r['CHK04'];
                                $model->CHK05 = $r['CHK05'];
                                $model->CHK06 = $r['CHK06'];
                                $model->CHK07 = $r['CHK07'];
                                $model->CHK08 = $r['CHK08'];
                                $model->CHK09 = $r['CHK09'];
                                $model->CHK10 = $r['CHK10'];
                                $model->CHK11 = $r['CHK11'];
                                $model->CHK12 = $r['CHK12'];
                                $model->CHKJMLTRK = $r['CHKJMLTRK'];
                                $model->CHKPERSEN = $r['CHKPERSEN'];
                                $model->CHKRATA2 = $r['CHKRATA2'];
                                $model->CHKRATA2GJ = $r['CHKRATA2GJ'];
                                $model->KDLOKASI = $r['KDLOKASI'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "VL":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                                    'REGISTER' => '' . $rs->Fields['REGISTER'] . '',
                                    'KDVALAS' => '' . $rs->Fields['KDVALAS'] . '',
                                    'NILAIVALAS' => '' . $rs->Fields['NILAIVALAS'] . '',
                                    'EKUIUSD' => '' . $rs->Fields['EKUIUSD'] . '',
                                    'EKUIRPH' => '' . $rs->Fields['EKUIRPH'] . '',
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DValas;
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->REGISTER = $r['REGISTER'];
                                $model->KDVALAS = $r['KDVALAS'];
                                $model->NILAIVALAS = $r['NILAIVALAS'];
                                $model->EKUIUSD = $r['EKUIUSD'];
                                $model->EKUIRPH = $r['EKUIRPH'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;

                        case "US":

                            $query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
                            $data = array();
                            while (!$rs->EOF) {
                                array_push($data, array(
                                    'NODIPA' => '' . $rs->Fields['NODIPA'] . '',
                                    'NOMOR' => '' . $rs->Fields['NOMOR'] . '',
                                    'THANG' => '' . $rs->Fields['THANG'] . '',
                                    'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                                    'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                                    'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                                    'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                                    'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                                    'SIFAT' => '' . $rs->Fields['SIFAT'] . '',
                                    'TGL' => '' . $rs->Fields['TGL'] . '',
                                    'LAMPIRAN' => '' . $rs->Fields['LAMPIRAN'] . '',
                                    'HAL' => '' . $rs->Fields['HAL'] . '',
                                    'YTH1' => '' . $rs->Fields['YTH1'] . '',
                                    'YTH2' => '' . $rs->Fields['YTH2'] . '',
                                    'YTH3' => '' . $rs->Fields['YTH3'] . '',
                                    'DASAR1' => '' . $rs->Fields['DASAR1'] . '',
                                    'DASAR2' => '' . $rs->Fields['DASAR2'] . '',
                                    'DASAR3' => '' . $rs->Fields['DASAR3'] . '',
                                    'DASAR4' => '' . $rs->Fields['DASAR4'] . '',
                                    'DASAR5' => '' . $rs->Fields['DASAR5'] . '',
                                    'DASAR6' => '' . $rs->Fields['DASAR6'] . '',
                                    'DASAR7' => '' . $rs->Fields['DASAR7'] . '',
                                    'DASAR8' => '' . $rs->Fields['DASAR8'] . '',
                                    'DASAR9' => '' . $rs->Fields['DASAR9'] . '',
                                    'DASAR10' => '' . $rs->Fields['DASAR10'] . '',
                                    'JELAS1' => '' . $rs->Fields['JELAS1'] . '',
                                    'JELAS2' => '' . $rs->Fields['JELAS2'] . '',
                                    'JELAS3' => '' . $rs->Fields['JELAS3'] . '',
                                    'JELAS4' => '' . $rs->Fields['JELAS4'] . '',
                                    'JELAS5' => '' . $rs->Fields['JELAS5'] . '',
                                    'JELAS6' => '' . $rs->Fields['JELAS6'] . '',
                                    'JELAS7' => '' . $rs->Fields['JELAS7'] . '',
                                    'JELAS8' => '' . $rs->Fields['JELAS8'] . '',
                                    'JELAS9' => '' . $rs->Fields['JELAS9'] . '',
                                    'JELAS10' => '' . $rs->Fields['JELAS10'] . '',
                                    'NIP' => '' . $rs->Fields['NIP'] . '',
                                    'TEMBUSAN1' => '' . $rs->Fields['TEMBUSAN1'] . '',
                                    'TEMBUSAN2' => '' . $rs->Fields['TEMBUSAN2'] . '',
                                    'TEMBUSAN3' => '' . $rs->Fields['TEMBUSAN3'] . '',
                                    'TEMBUSAN4' => '' . $rs->Fields['TEMBUSAN4'] . '',
                                    'TEMBUSAN5' => '' . $rs->Fields['TEMBUSAN5'] . '',
                                    'TEMBUSAN6' => '' . $rs->Fields['TEMBUSAN6'] . '',
                                        )
                                );
                                $rs->MoveNext();
                            }

                            foreach ($data as $val => $r) {
                                $model = new DUsulsah;
                                $model->NODIPA = $r['NODIPA'];
                                $model->NOMOR = $r['NOMOR'];
                                $model->THANG = $r['THANG'];
                                $model->KDJENDOK = $r['KDJENDOK'];
                                $model->KDSATKER = $r['KDSATKER'];
                                $model->KDDEPT = $r['KDDEPT'];
                                $model->KDUNIT = $r['KDUNIT'];
                                $model->KDDEKON = $r['KDDEKON'];
                                $model->SIFAT = $r['SIFAT'];
                                $model->TGL = $r['TGL'];
                                $model->HAL = $r['HAL'];
                                $model->YTH1 = $r['YTH1'];
                                $model->YTH2 = $r['YTH2'];
                                $model->YTH3 = $r['YTH3'];
                                $model->DASAR1 = $r['DASAR1'];
                                $model->DASAR2 = $r['DASAR2'];
                                $model->DASAR3 = $r['DASAR3'];
                                $model->DASAR4 = $r['DASAR4'];
                                $model->DASAR5 = $r['DASAR5'];
                                $model->DASAR6 = $r['DASAR6'];
                                $model->DASAR7 = $r['DASAR7'];
                                $model->DASAR8 = $r['DASAR8'];
                                $model->DASAR9 = $r['DASAR9'];
                                $model->DASAR10 = $r['DASAR10'];
                                $model->JELAS1 = $r['JELAS1'];
                                $model->JELAS2 = $r['JELAS2'];
                                $model->JELAS3 = $r['JELAS3'];
                                $model->JELAS4 = $r['JELAS4'];
                                $model->JELAS5 = $r['JELAS5'];
                                $model->JELAS6 = $r['JELAS6'];
                                $model->JELAS7 = $r['JELAS7'];
                                $model->JELAS8 = $r['JELAS8'];
                                $model->JELAS9 = $r['JELAS9'];
                                $model->JELAS10 = $r['JELAS10'];
                                $model->NIP = $r['NIP'];
                                $model->TEMBUSAN1 = $r['TEMBUSAN1'];
                                $model->TEMBUSAN2 = $r['TEMBUSAN2'];
                                $model->TEMBUSAN3 = $r['TEMBUSAN3'];
                                $model->TEMBUSAN4 = $r['TEMBUSAN4'];
                                $model->TEMBUSAN5 = $r['TEMBUSAN5'];
                                $model->TEMBUSAN6 = $r['TEMBUSAN6'];
                                $model->save();
                            }
                            $conn->Close();
                            unlink($upload_path . $fileName);
                            break;
                        default;
                    }
                }
            
//                if( Yii::app( )->user->hasState( 'images' ) ) {
//                    $userImages = Yii::app( )->user->getState( 'images' );
//                } else {
//                    $userImages = array();
//                }
//                 $userImages[] = array(
//                    "path" => $path.$filename,
//                    //the same file or a thumb version that you generated
//                    "thumb" => $path.$filename,
//                    "filename" => $filename,
//                    'size' => $model->size,
//                    'mime' => $model->mime_type,
//                    'name' => $model->name,
//                );
//                Yii::app( )->user->setState( 'images', $userImages );
 
                //Now we need to tell our widget that the upload was succesfull
                //We do so, using the json structure defined in
                // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup
                echo json_encode( array( array(
                        "name" => $filenya,
                        "type" => '12',
                        "size" => 'nn',
                        "url" => $publicPath.$filenya,
                        "thumbnail_url" => $publicPath."thumbs/$filenya",
                        "delete_url" => $this->createUrl( "upload", array(
                            "_method" => "delete",
                            "file" => $filenya
                        ) ),
                        "delete_type" => "POST"
                    ) ) );
            } else {
                //If the upload failed for some reason we log some data and let the widget know
                echo json_encode( array( 
                    array( "error" => $model->getErrors( 'file' ),
                ) ) );
                Yii::log( "XUploadAction: ".CVarDumper::dumpAsString( $model->getErrors( ) ),
                    CLogger::LEVEL_ERROR, "xupload.actions.XUploadAction" 
                );
            }
        } else {
            throw new CHttpException( 500, "Could not upload file" );
        }
    }
    }

    public function actionRestSakpa() {
        /*return array(
            'upload' => array(
                'class' => 'xupload.actions.XUploadAction',
                'path' => Yii::app()->getBasePath() . "/../temp",
                "publicPath" => Yii::app()->getBaseUrl() . "/temp"),
            );*/
        Yii::import("xupload.models.XUploadForm");
        $path = Yii::app()->getBasePath() . "/../temp_sakpa/";
        $publicPath = Yii::app()->getBaseUrl() . "/temp_sakpa";
        header( 'Vary: Accept' );
    if( isset( $_SERVER['HTTP_ACCEPT'] ) 
        && (strpos( $_SERVER['HTTP_ACCEPT'], 'application/json' ) !== false) ) {
        header( 'Content-type: application/json' );
    } else {
        header( 'Content-type: text/plain' );
    }
 
    //Here we check if we are deleting and uploaded file
    if( isset( $_GET["_method"] ) ) {
        if( $_GET["_method"] == "delete" ) {
            if( $_GET["file"][0] !== '.' ) {
                $file = $path.$_GET["file"];
                if( is_file( $file ) ) {
                    unlink( $file );
                }
            }
            echo json_encode( true );
        }
    } else {
        $model = new XUploadForm;
        $model->file = CUploadedFile::getInstance( $model, 'file' );
        //We check that the file was successfully uploaded
        if( $model->file !== null ) {
            //Grab some data
            $model->mime_type = $model->file->getType( );
            $model->size = $model->file->getSize( );
            $model->name = $model->file->getName( );
            //(optional) Generate a random name for our file
            $filename = $model->name;
            //$filename .= ".".$model->file->getExtensionName( );
            if( $model->validate( ) ) {
                //Move our file to our temporary dir
                $model->file->saveAs( $path.$filename );
                chmod( $path.$filename, 0777 );
                $filenya=$filename;
                $upload_path=$path;
				
                exec(getenv("DOCUMENT_ROOT") . '/rkakl-thinkfrogs/7za x ' . $path . $filenya);
				//echo getenv("DOCUMENT_ROOT") . '/rkakl-thinkfrogs/temp_sakpa/7za x ' . $path . $filenya;
                unlink($path . $filenya);
                $dir = $path;
                $dh = opendir($dir);
                $files = array();
                while (($file = readdir($dh)) !== false) {
                    $files[] = $file;
                }
                unset($files[0]);
                unset($files[1]);

                foreach ($files as $key => $fileName) {

                    set_time_limit(0);
                    $restore_path = str_replace("/", "\\", $path);
                    $conn = new COM("ADODB.Connection");
                    $conn->Open('Provider=VFPOLEDB.1;Data Source="' . $restore_path . $fileName . '";Password="";Collating Sequence=MACHINE');
                    switch (substr($fileName, 0, 5)) {
                        case "T_BMN":
							$query = "SELECT * FROM " . $fileName;
                            $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
							
                            $data = array();
							while (!$rs->EOF) {
                                array_push($data, array(
									'THNANG' => '' . $rs->Fields['THNANG'] . '',
									//'KDBAES1' => '' . $rs->Fields['KDBAES1'] . '',
									'KDWILAYAH' => '' . $rs->Fields['KDWILAYAH'] . '',
									'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
									'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
									'PERASET' => '' . $rs->Fields['PERASET'] . '',
									'KD_PERK' => '' . $rs->Fields['KD_PERK'] . '',
									'RPH' => '' . $rs->Fields['RPH'] . '',
									'TGL_BUKU' => '' . $rs->Fields['TGL_BUKU'] . '',
									'JNS_TRN' => '' . $rs->Fields['JNS_TRN'] . '',
									'TGL_SP2D' => '' . $rs->Fields['TGL_SP2D'] . '',
									'NO_SP2D' => '' . $rs->Fields['NO_SP2D'] . '',
									'BKPK' => '' . $rs->Fields['BKPK'] . '',
									'TGLKIRIM' => '' . $rs->Fields['TGLKIRIM'] . '',
									'PERIODE' => '' . $rs->Fields['PERIODE'] . '',
									'KDBAPEL' => '' . $rs->Fields['KDBAPEL'] . '',
									'KDES1PEL' => '' . $rs->Fields['KDES1PEL'] . '',
									'KDBLU' => '' . $rs->Fields['KDBLU'] . '',
									'KDKPPN' => '' . $rs->Fields['KDKPPN'] . '',
                                    
                                        //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                                        )
                                );
                                $rs->MoveNext();
                            }
							
							foreach ($data as $val => $r) {
                                $model = new SakpaTSpmBmn;
                                $model->THNANG = $r['THNANG'];
								//$model->KDWILAYAH = $r['KDBAES1'];
                                $model->KDWILAYAH = $r['KDWILAYAH'];
                                $model->KDSATKER = $r['KDSATKER'];
								$model->KDDEKON = $r['KDDEKON'];
                                $model->PERASET = $r['PERASET'];
                                $model->KD_PERK = $r['KD_PERK'];
                                $model->RPH = $r['RPH'];
                                //$model->TGL_BUKU = $r['TGL_BUKU'];
								$model->JNS_TRN = $r['JNS_TRN'];
                               // $model->TGL_SP2D = $r['TGL_SP2D'];
                                $model->NO_SP2D = $r['NO_SP2D'];
								$model->BKPK = $r['BKPK'];
                                //$model->TGLKIRIM = $r['TGLKIRIM'];
                                //$model->PERIODE = $r['PERIODE'];
								$model->KDBAPEL = $r['KDBAPEL'];
                                $model->KDES1PEL = $r['KDES1PEL'];
                                $model->KDBLU = $r['KDBLU'];
								$model->KDKPPN = $r['KDKPPN'];
                                
                                //  $model->_NullFlags=$r['_NullFlags'];
                                $model->save();
                            }
                            $conn->Close();
                            
							break;
                        
                        default;
                    }
					unlink($upload_path . $fileName);
                }
            
//                if( Yii::app( )->user->hasState( 'images' ) ) {
//                    $userImages = Yii::app( )->user->getState( 'images' );
//                } else {
//                    $userImages = array();
//                }
//                 $userImages[] = array(
//                    "path" => $path.$filename,
//                    //the same file or a thumb version that you generated
//                    "thumb" => $path.$filename,
//                    "filename" => $filename,
//                    'size' => $model->size,
//                    'mime' => $model->mime_type,
//                    'name' => $model->name,
//                );
//                Yii::app( )->user->setState( 'images', $userImages );
 
                //Now we need to tell our widget that the upload was succesfull
                //We do so, using the json structure defined in
                // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup
                echo json_encode( array( array(
                        "name" => $filenya,
                        "type" => '12',
                        "size" => 'nn',
                        "url" => $publicPath.$filenya,
                        "thumbnail_url" => $publicPath."thumbs/$filenya",
                        "delete_url" => $this->createUrl( "upload", array(
                            "_method" => "delete",
                            "file" => $filenya
                        ) ),
                        "delete_type" => "POST"
                    ) ) );
            } else {
                //If the upload failed for some reason we log some data and let the widget know
                echo json_encode( array( 
                    array( "error" => $model->getErrors( 'file' ),
                ) ) );
                Yii::log( "XUploadAction: ".CVarDumper::dumpAsString( $model->getErrors( ) ),
                    CLogger::LEVEL_ERROR, "xupload.actions.XUploadAction" 
                );
            }
        } else {
            throw new CHttpException( 500, "Could not upload file" );
        }
    }
    }

    function ak($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                "THANG" => '' . $rs->Fields['THANG'] . '',
                "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                "PROSENPHLN" => '' . $rs->Fields['PROSENPHLN'] . '',
                "PROSENRKP" => '' . $rs->Fields['PROSENRKP'] . '',
                "PROSENRMP" => '' . $rs->Fields['PROSENRMP'] . '',
                "KPPNRKP" => '' . $rs->Fields['KPPNRKP'] . '',
                "KPPNRMP" => '' . $rs->Fields['KPPNRMP'] . '',
                "KPPNPHLN" => '' . $rs->Fields['KPPNPHLN'] . '',
                "REGDAM" => '' . $rs->Fields['REGDAM'] . '',
                "KDLUNCURAN" => '' . $rs->Fields['KDLUNCURAN'] . '',
                "KDIB" => '' . $rs->Fields['KDIB'] . '',
                    //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DAkun;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->KDKMPNEN = $r['KDKMPNEN'];
            $model->KDSKMPNEN = $r['KDSKMPNEN'];
            $model->KDAKUN = $r['KDAKUN'];
            $model->KDKPPN = $r['KDKPPN'];
            $model->KDBEBAN = $r['KDBEBAN'];
            $model->KDJNSBAN = $r['KDJNSBAN'];
            $model->KDCTARIK = $r['KDCTARIK'];
            $model->REGISTER = $r['REGISTER'];
            $model->CARAHITUNG = $r['CARAHITUNG'];
            $model->PROSENPHLN = $r['PROSENPHLN'];
            $model->PROSENRKP = $r['PROSENRKP'];
            $model->PROSENRMP = $r['PROSENRMP'];
            $model->KPPNRKP = $r['KPPNRKP'];
            $model->KPPNRMP = $r['KPPNRMP'];
            $model->KPPNPHLN = $r['KPPNPHLN'];
            $model->REGDAM = $r['REGDAM'];
            $model->KDLUNCURAN = $r['KDLUNCURAN'];
            $model->KDIB = $r['KDIB'];
            //  $model->_NullFlags=$r['_NullFlags'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function BL($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                "THANG" => '' . $rs->Fields['THANG'] . '',
                "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                "KDBLOKIR" => '' . $rs->Fields['KDBLOKIR'] . '',
                "URAIBLOKIR" => '' . $rs->Fields['URAIBLOKIR'] . '',
                "KDIB" => '' . $rs->Fields['KDIB'] . '',
                    //"_NullFlags"=>''.$rs->Fields[''].''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DBlokir;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->KDKMPNEN = $r['KDKMPNEN'];
            $model->KDSKMPNEN = $r['KDSKMPNEN'];
            $model->KDAKUN = $r['KDAKUN'];
            $model->KDKPPN = $r['KDKPPN'];
            $model->KDBEBAN = $r['KDBEBAN'];
            $model->KDJNSBAN = $r['KDJNSBAN'];
            $model->KDCTARIK = $r['KDCTARIK'];
            $model->REGISTER = $r['REGISTER'];
            $model->CARAHITUNG = $r['CARAHITUNG'];
            $model->KDBLOKIR = $r['KDBLOKIR'];
            $model->URAIBLOKIR = $r['URAIBLOKIR'];
            $model->KDIB = $r['KDIB'];
            //   $model->_NullFlags=$r['_NullFlags'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function CT($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                "THANG" => '' . $rs->Fields['THANG'] . '',
                "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                "KDIB" => '' . $rs->Fields['KDIB'] . '',
                "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                "KET" => '' . $rs->Fields['KET'] . '',
                "KET2" => '' . $rs->Fields['KET2'] . '',
                    // "_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DCttakun;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDIB = $r['KDIB'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->KDKMPNEN = $r['KDKMPNEN'];
            $model->KDSKMPNEN = $r['KDSKMPNEN'];
            $model->KDAKUN = $r['KDAKUN'];
            $model->KDKPPN = $r['KDKPPN'];
            $model->KDBEBAN = $r['KDBEBAN'];
            $model->KDJNSBAN = $r['KDJNSBAN'];
            $model->KDCTARIK = $r['KDCTARIK'];
            $model->REGISTER = $r['REGISTER'];
            $model->CARAHITUNG = $r['CARAHITUNG'];
            $model->KET = $r['KET'];
            $model->KET2 = $r['KET2'];
            //	   $model->_NullFlags=$r['_NullFlags'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function IT($fileName, $conn, $upload_path) {
        $restore_path = str_replace("/", "\\", $upload_path);
        $conn = new COM("ADODB.Connection");
        $conn->Open('Provider=VFPOLEDB.1;Data Source="' . $restore_path . $fileName . '";Password="";Collating Sequence=MACHINE');
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                "THANG" => '' . $rs->Fields['THANG'] . '',
                "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                "KDSKMPNEN" => '' . $rs->Fields['KDSKMPNEN'] . '',
                "KDAKUN" => '' . $rs->Fields['KDAKUN'] . '',
                "KDKPPN" => '' . $rs->Fields['KDKPPN'] . '',
                "KDBEBAN" => '' . $rs->Fields['KDBEBAN'] . '',
                "KDJNSBAN" => '' . $rs->Fields['KDJNSBAN'] . '',
                "KDCTARIK" => '' . $rs->Fields['KDCTARIK'] . '',
                "REGISTER" => '' . $rs->Fields['REGISTER'] . '',
                "CARAHITUNG" => '' . $rs->Fields['CARAHITUNG'] . '',
                "HEADER1" => '' . $rs->Fields['HEADER1'] . '',
                "HEADER2" => '' . $rs->Fields['HEADER2'] . '',
                "KDHEADER" => '' . $rs->Fields['KDHEADER'] . '',
                "NOITEM" => '' . $rs->Fields['NOITEM'] . '',
                "NMITEM" => '' . $rs->Fields['NMITEM'] . '',
                "VOL1" => '' . $rs->Fields['VOL1'] . '',
                "SAT1" => '' . $rs->Fields['SAT1'] . '',
                "VOL2" => '' . $rs->Fields['VOL2'] . '',
                "SAT2" => '' . $rs->Fields['SAT2'] . '',
                "VOL3" => '' . $rs->Fields['VOL3'] . '',
                "SAT3" => '' . $rs->Fields['SAT3'] . '',
                "VOL4" => '' . $rs->Fields['VOL4'] . '',
                "SAT4" => '' . $rs->Fields['SAT4'] . '',
                "VOLKEG" => '' . $rs->Fields['VOLKEG'] . '',
                "SATKEG" => '' . $rs->Fields['SATKEG'] . '',
                "HARGASAT" => '' . $rs->Fields['HARGASAT'] . '',
                "JUMLAH" => '' . $rs->Fields['JUMLAH'] . '',
                "PAGUPHLN" => '' . $rs->Fields['PAGUPHLN'] . '',
                "PAGURMP" => '' . $rs->Fields['PAGURMP'] . '',
                "PAGURKP" => '' . $rs->Fields['PAGURKP'] . '',
                "KDBLOKIR" => '' . $rs->Fields['KDBLOKIR'] . '',
                "BLOKIRPHLN" => '' . $rs->Fields['BLOKIRPHLN'] . '',
                "BLOKIRRMP" => '' . $rs->Fields['BLOKIRRMP'] . '',
                "BLOKIRRKP" => '' . $rs->Fields['BLOKIRRKP'] . '',
                "RPHBLOKIR" => '' . $rs->Fields['RPHBLOKIR'] . '',
                "KDCOPY" => '' . $rs->Fields['KDCOPY'] . '',
                "KDABT" => '' . $rs->Fields['KDABT'] . '',
                "KDSBU" => '' . $rs->Fields['KDSBU'] . '',
                "VOLSBK" => '' . $rs->Fields['VOLSBK'] . '',
                "VOLRKAKL" => '' . $rs->Fields['VOLRKAKL'] . '',
                "BLNKONTRAK" => '' . $rs->Fields['BLNKONTRAK'] . '',
                "NOKONTRAK" => '' . $rs->Fields['NOKONTRAK'] . '',
                "TGKONTRAK" => '' . $rs->Fields['TGKONTRAK'] . '',
                "NILKONTRAK" => '' . $rs->Fields['NILKONTRAK'] . '',
                "JANUARI" => '' . $rs->Fields['JANUARI'] . '',
                "PEBRUARI" => '' . $rs->Fields['PEBRUARI'] . '',
                "MARET" => '' . $rs->Fields['MARET'] . '',
                "APRIL" => '' . $rs->Fields['APRIL'] . '',
                "MEI" => '' . $rs->Fields['MEI'] . '',
                "JUNI" => '' . $rs->Fields['JUNI'] . '',
                "JULI" => '' . $rs->Fields['JULI'] . '',
                "AGUSTUS" => '' . $rs->Fields['AGUSTUS'] . '',
                "SEPTEMBER" => '' . $rs->Fields['SEPTEMBER'] . '',
                "OKTOBER" => '' . $rs->Fields['OKTOBER'] . '',
                "NOPEMBER" => '' . $rs->Fields['NOPEMBER'] . '',
                "DESEMBER" => '' . $rs->Fields['DESEMBER'] . '',
                "JMLTUNDA" => '' . $rs->Fields['JMLTUNDA'] . '',
                "KDLUNCURAN" => '' . $rs->Fields['KDLUNCURAN'] . '',
                "JMLABT" => '' . $rs->Fields['JMLABT'] . '',
                "NOREV" => '' . $rs->Fields['NOREV'] . '',
                "KDUBAH" => '' . $rs->Fields['KDUBAH'] . '',
                "KURS" => '' . $rs->Fields['KURS'] . '',
                "INDEXKPJM" => '' . $rs->Fields['INDEXKPJM'] . '',
                "KDIB" => '' . $rs->Fields['KDIB'] . '',
                    //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DItem;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->KDKMPNEN = $r['KDKMPNEN'];
            $model->KDSKMPNEN = $r['KDSKMPNEN'];
            $model->KDAKUN = $r['KDAKUN'];
            $model->KDKPPN = $r['KDKPPN'];
            $model->KDBEBAN = $r['KDBEBAN'];
            $model->KDJNSBAN = $r['KDJNSBAN'];
            $model->KDCTARIK = $r['KDCTARIK'];
            $model->REGISTER = $r['REGISTER'];
            $model->CARAHITUNG = $r['CARAHITUNG'];
            $model->HEADER1 = $r['HEADER1'];
            $model->HEADER2 = $r['HEADER2'];
            $model->KDHEADER = $r['KDHEADER'];
            $model->NOITEM = $r['NOITEM'];
            $model->NMITEM = $r['NMITEM'];
            $model->VOL1 = $r['VOL1'];
            $model->SAT1 = $r['SAT1'];
            $model->VOL2 = $r['VOL2'];
            $model->SAT2 = $r['SAT2'];
            $model->VOL3 = $r['VOL3'];
            $model->SAT3 = $r['SAT3'];
            $model->VOL4 = $r['VOL4'];
            $model->SAT4 = $r['SAT4'];
            $model->VOLKEG = $r['VOLKEG'];
            $model->SATKEG = $r['SATKEG'];
            $model->HARGASAT = $r['HARGASAT'];
            $model->JUMLAH = $r['JUMLAH'];
            $model->PAGUPHLN = $r['PAGUPHLN'];
            $model->PAGURMP = $r['PAGURMP'];
            $model->PAGURKP = $r['PAGURKP'];
            $model->KDBLOKIR = $r['KDBLOKIR'];
            $model->BLOKIRPHLN = $r['BLOKIRPHLN'];
            $model->BLOKIRRMP = $r['BLOKIRRMP'];
            $model->BLOKIRRKP = $r['BLOKIRRKP'];
            $model->RPHBLOKIR = $r['RPHBLOKIR'];
            $model->KDCOPY = $r['KDCOPY'];
            $model->KDABT = $r['KDABT'];
            $model->KDSBU = $r['KDSBU'];
            $model->VOLSBK = $r['VOLSBK'];
            $model->VOLRKAKL = $r['VOLRKAKL'];
            $model->BLNKONTRAK = $r['BLNKONTRAK'];
            $model->NOKONTRAK = $r['NOKONTRAK'];
            $model->TGKONTRAK = $r['TGKONTRAK'];
            $model->NILKONTRAK = $r['NILKONTRAK'];
            $model->JANUARI = $r['JANUARI'];
            $model->PEBRUARI = $r['PEBRUARI'];
            $model->MARET = $r['MARET'];
            $model->APRIL = $r['APRIL'];
            $model->MEI = $r['MEI'];
            $model->JUNI = $r['JUNI'];
            $model->JULI = $r['JULI'];
            $model->AGUSTUS = $r['AGUSTUS'];
            $model->SEPTEMBER = $r['SEPTEMBER'];
            $model->OKTOBER = $r['OKTOBER'];
            $model->NOPEMBER = $r['NOPEMBER'];
            $model->DESEMBER = $r['DESEMBER'];
            $model->JMLTUNDA = $r['JMLTUNDA'];
            $model->KDLUNCURAN = $r['KDLUNCURAN'];
            $model->JMLABT = $r['JMLABT'];
            $model->NOREV = $r['NOREV'];
            $model->KDUBAH = $r['KDUBAH'];
            $model->KURS = $r['KURS'];
            $model->INDEXKPJM = $r['INDEXKPJM'];
            $model->KDIB = $r['KDIB'];
            //	   $model->_NullFlags=$r['_NullFlags'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function KA($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                "THANG" => '' . $rs->Fields['THANG'] . '',
                "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                "KPA" => '' . $rs->Fields['KPA'] . '',
                "BENDAHARA" => '' . $rs->Fields['BENDAHARA'] . '',
                "PPSPM" => '' . $rs->Fields['PPSPM'] . '',
                "TEST" => '' . $rs->Fields['TEST'] . '',
                "STATUSBLU" => '' . $rs->Fields['STATUSBLU'] . '',
                "PPLPNBP" => '' . $rs->Fields['PPLPNBP'] . '',
                "ESAWK" => '' . $rs->Fields['ESAWK'] . '',
                "ESAWKGUNA" => '' . $rs->Fields['ESAWKGUNA'] . '',
                "ESAKK" => '' . $rs->Fields['ESAKK'] . '',
                "AMBANGBATS" => '' . $rs->Fields['AMBANGBATS'] . '',
                "NPWP" => '' . $rs->Fields['NPWP'] . '',
                "NODIPA" => '' . $rs->Fields['NODIPA'] . '',
                "NOSPRKAKL" => '' . $rs->Fields['NOSPRKAKL'] . '',
                "THSPRKAKL" => '' . $rs->Fields['THSPRKAKL'] . '',
                "DASARDIPA" => '' . $rs->Fields['DASARDIPA'] . '',
                "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . ''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DKpa;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KPA = $r['KPA'];
            $model->BENDAHARA = $r['BENDAHARA'];
            $model->PPSPM = $r['PPSPM'];
            $model->TEST = $r['TEST'];
            $model->STATUSBLU = $r['STATUSBLU'];
            $model->PPLPNBP = $r['PPLPNBP'];
            $model->ESAWK = $r['ESAWK'];
            $model->ESAWKGUNA = $r['ESAWKGUNA'];
            $model->ESAKK = $r['ESAKK'];
            $model->AMBANGBATS = $r['AMBANGBATS'];
            $model->NPWP = $r['NPWP'];
            $model->NODIPA = $r['NODIPA'];
            $model->NOSPRKAKL = $r['NOSPRKAKL'];
            $model->THSPRKAKL = $r['THSPRKAKL'];
            $model->DASARDIPA = $r['DASARDIPA'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function KM($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                "THANG" => '' . $rs->Fields['THANG'] . '',
                "KDJENDOK" => '' . $rs->Fields['KDJENDOK'] . '',
                "KDSATKER" => '' . $rs->Fields['KDSATKER'] . '',
                "KDDEPT" => '' . $rs->Fields['KDDEPT'] . '',
                "KDUNIT" => '' . $rs->Fields['KDUNIT'] . '',
                "KDPROGRAM" => '' . $rs->Fields['KDPROGRAM'] . '',
                "KDGIAT" => '' . $rs->Fields['KDGIAT'] . '',
                "KDOUTPUT" => '' . $rs->Fields['KDOUTPUT'] . '',
                "KDLOKASI" => '' . $rs->Fields['KDLOKASI'] . '',
                "KDKABKOTA" => '' . $rs->Fields['KDKABKOTA'] . '',
                "KDDEKON" => '' . $rs->Fields['KDDEKON'] . '',
                "KDSOUTPUT" => '' . $rs->Fields['KDSOUTPUT'] . '',
                "KDKMPNEN" => '' . $rs->Fields['KDKMPNEN'] . '',
                "KDBIAYA" => '' . $rs->Fields['KDBIAYA'] . '',
                "KDSBIAYA" => '' . $rs->Fields['KDSBIAYA'] . '',
                "URKMPNEN" => '' . $rs->Fields['URKMPNEN'] . '',
                "KDTEMA" => '' . $rs->Fields['KDTEMA'] . '',
                "RPHPLS1" => '' . $rs->Fields['RPHPLS1'] . '',
                "RPHPLS2" => '' . $rs->Fields['RPHPLS2'] . '',
                "RPHPLS3" => '' . $rs->Fields['RPHPLS3'] . '',
                "RPHMIN1" => '' . $rs->Fields['RPHMIN1'] . '',
                "THANGAWAL" => '' . $rs->Fields['THANGAWAL'] . '',
                "THANGAKHIR" => '' . $rs->Fields['THANGAKHIR'] . '',
                "INDEKSKALI" => '' . $rs->Fields['INDEKSKALI'] . '',
                "KDIB" => '' . $rs->Fields['KDIB'] . '',
                "INDEKSOUT" => '' . $rs->Fields['INDEKSOUT'] . '',
                    //"_NullFlags"=>''.$rs->Fields['_NullFlags'].'',
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DKmpnen;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->KDKMPNEN = $r['KDKMPNEN'];
            $model->KDBIAYA = $r['KDBIAYA'];
            $model->KDSBIAYA = $r['KDSBIAYA'];
            $model->URKMPNEN = $r['URKMPNEN'];
            $model->KDTEMA = $r['KDTEMA'];
            $model->RPHPLS1 = $r['RPHPLS1'];
            $model->RPHPLS2 = $r['RPHPLS2'];
            $model->RPHPLS3 = $r['RPHPLS3'];
            $model->RPHMIN1 = $r['RPHMIN1'];
            $model->THANGAWAL = $r['THANGAWAL'];
            $model->THANGAKHIR = $r['THANGAKHIR'];
            $model->INDEKSKALI = $r['INDEKSKALI'];
            $model->KDIB = $r['KDIB'];
            $model->INDEKSOUT = $r['INDEKSOUT'];
            //	   $model->_NullFlags=$r['_NullFlags'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function OU($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                'KDOUTPUT' => '' . $rs->Fields['KDOUTPUT'] . '',
                'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                'KDKABKOTA' => '' . $rs->Fields['KDKABKOTA'] . '',
                'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                'VOLMIN1' => '' . $rs->Fields['VOLMIN1'] . '',
                'VOL' => '' . $rs->Fields['VOL'] . '',
                'VOLPLS1' => '' . $rs->Fields['VOLPLS1'] . '',
                'VOLPLS2' => '' . $rs->Fields['VOLPLS2'] . '',
                'VOLPLS3' => '' . $rs->Fields['VOLPLS3'] . '',
                'RPHMIN1' => '' . $rs->Fields['RPHMIN1'] . '',
                'RPHPLS1' => '' . $rs->Fields['RPHPLS1'] . '',
                'RPHPLS2' => '' . $rs->Fields['RPHPLS2'] . '',
                'RPHPLS3' => '' . $rs->Fields['RPHPLS3'] . '',
                'SBKKET' => '' . $rs->Fields['SBKKET'] . '',
                'SBKMIN1' => '' . $rs->Fields['SBKMIN1'] . '',
                'KDSB' => '' . $rs->Fields['KDSB'] . '',
                'KDJOUTPUT' => '' . $rs->Fields['KDJOUTPUT'] . '',
                'THANGAWAL' => '' . $rs->Fields['THANGAWAL'] . '',
                'THANGAKHIR' => '' . $rs->Fields['THANGAKHIR'] . '',
                'KDTEMA' => '' . $rs->Fields['KDTEMA'] . '',
                'KDIB' => '' . $rs->Fields['KDIB'] . '',
                'KDAUTO' => '' . $rs->Fields['KDAUTO'] . ''
                    //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DOutput;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->VOLMIN1 = $r['VOLMIN1'];
            $model->VOL = $r['VOL'];
            $model->VOLPLS1 = $r['VOLPLS1'];
            $model->VOLPLS2 = $r['VOLPLS2'];
            $model->VOLPLS3 = $r['VOLPLS3'];
            $model->RPHMIN1 = $r['RPHMIN1'];
            $model->RPHPLS1 = $r['RPHPLS1'];
            $model->RPHPLS3 = $r['RPHPLS3'];
            $model->SBKKET = $r['SBKKET'];
            $model->SBKMIN1 = $r['SBKMIN1'];
            $model->KDSB = $r['KDSB'];
            $model->KDJOUTPUT = $r['KDJOUTPUT'];
            $model->THANGAWAL = $r['THANGAWAL'];
            $model->THANGAKHIR = $r['THANGAKHIR'];
            $model->KDTEMA = $r['KDTEMA'];
            $model->KDIB = $r['KDIB'];
            $model->KDAUTO = $r['KDAUTO'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function PD($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                'KDAKUN' => '' . $rs->Fields['KDAKUN'] . '',
                'KDPNBPF' => '' . $rs->Fields['KDPNBPF'] . '',
                'RPHMIN1' => '' . $rs->Fields['RPHMIN1'] . '',
                'RPHPDPT' => '' . $rs->Fields['RPHPDPT'] . '',
                'RPHPLS1' => '' . $rs->Fields['RPHPLS1'] . '',
                'RPHPLS2' => '' . $rs->Fields['RPHPLS2'] . '',
                'RPHPLS3' => '' . $rs->Fields['RPHPLS3'] . '',
                    //"_NullFlags"=>''.$rs->Fields['_NullFlags'].''
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DPdpt;
            $model->THANG = $r['THANG'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDAKUN = $r['KDAKUN'];
            $model->KDPNBPF = $r['KDPNBPF'];
            $model->RPHMIN1 = $r['RPHMIN1'];
            $model->RPHPDPT = $r['RPHPDPT'];
            $model->RPHPLS1 = $r['RPHPLS1'];
            $model->RPHPLS2 = $r['RPHPLS2'];
            $model->RPHPLS3 = $r['RPHPLS3'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function SM($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                'KDOUTPUT' => '' . $rs->Fields['KDOUTPUT'] . '',
                'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                'KDKABKOTA' => '' . $rs->Fields['KDKABKOTA'] . '',
                'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                'KDSOUTPUT' => '' . $rs->Fields['KDSOUTPUT'] . '',
                'KDKMPNEN' => '' . $rs->Fields['KDKMPNEN'] . '',
                'KDSKMPNEN' => '' . $rs->Fields['KDSKMPNEN'] . '',
                'URSKMPNEN' => '' . $rs->Fields['URSKMPNEN'] . '',
                'KDIB' => '' . $rs->Fields['KDIB'] . '',
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DSkmpnen;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->KDKMPNEN = $r['KDKMPNEN'];
            $model->KDSKMPNEN = $r['KDSKMPNEN'];
            $model->URSKMPNEN = $r['URSKMPNEN'];
            $model->KDIB = $r['KDIB'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function SO($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                'KDOUTPUT' => '' . $rs->Fields['KDOUTPUT'] . '',
                'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                'KDKABKOTA' => '' . $rs->Fields['KDKABKOTA'] . '',
                'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                'KDSOUTPUT' => '' . $rs->Fields['KDSOUTPUT'] . '',
                'URSOUTPUT' => '' . $rs->Fields['URSOUTPUT'] . '',
                'SBMKVOL' => '' . $rs->Fields['SBMKVOL'] . '',
                'SBMKSAT' => '' . $rs->Fields['SBMKSAT'] . '',
                'SBMKMIN1' => '' . $rs->Fields['SBMKMIN1'] . '',
                'SBMKKET' => '' . $rs->Fields['SBMKKET'] . '',
                'KDSB' => '' . $rs->Fields['KDSB'] . '',
                'VOLSOUT' => '' . $rs->Fields['VOLSOUT'] . '',
                'KDIB' => '' . $rs->Fields['KDIB'] . '',
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DSoutput;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->KDOUTPUT = $r['KDOUTPUT'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->KDKABKOTA = $r['KDKABKOTA'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDSOUTPUT = $r['KDSOUTPUT'];
            $model->URSOUTPUT = $r['URSOUTPUT'];
            $model->SBMKVOL = $r['SBMKVOL'];
            $model->SBMKSAT = $r['SBMKSAT'];
            $model->SBMKMIN1 = $r['SBMKMIN1'];
            $model->SBMKKET = $r['SBMKKET'];
            $model->KDSB = $r['KDSB'];
            $model->VOLSOUT = $r['VOLSOUT'];
            $model->KDIB = $r['KDIB'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function TR($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                'KDFUNGSI' => '' . $rs->Fields['KDFUNGSI'] . '',
                'KDSFUNG' => '' . $rs->Fields['KDSFUNG'] . '',
                'KDPROGRAM' => '' . $rs->Fields['KDPROGRAM'] . '',
                'KDGIAT' => '' . $rs->Fields['KDGIAT'] . '',
                'RPHPAGU' => '' . $rs->Fields['RPHPAGU'] . '',
                'KDTRKTRM' => '' . $rs->Fields['KDTRKTRM'] . '',
                'JNSBELANJA' => '' . $rs->Fields['JNSBELANJA'] . '',
                'JML01' => '' . $rs->Fields['JML01'] . '',
                'JML02' => '' . $rs->Fields['JML02'] . '',
                'JML03' => '' . $rs->Fields['JML03'] . '',
                'JML04' => '' . $rs->Fields['JML04'] . '',
                'JML05' => '' . $rs->Fields['JML05'] . '',
                'JML06' => '' . $rs->Fields['JML06'] . '',
                'JML07' => '' . $rs->Fields['JML07'] . '',
                'JML08' => '' . $rs->Fields['JML08'] . '',
                'JML09' => '' . $rs->Fields['JML09'] . '',
                'JML10' => '' . $rs->Fields['JML10'] . '',
                'JML11' => '' . $rs->Fields['JML11'] . '',
                'JML12' => '' . $rs->Fields['JML12'] . '',
                'PERSEN01' => '' . $rs->Fields['PERSEN01'] . '',
                'PERSEN02' => '' . $rs->Fields['PERSEN02'] . '',
                'PERSEN03' => '' . $rs->Fields['PERSEN03'] . '',
                'PERSEN04' => '' . $rs->Fields['PERSEN04'] . '',
                'PERSEN05' => '' . $rs->Fields['PERSEN05'] . '',
                'PERSEN06' => '' . $rs->Fields['PERSEN06'] . '',
                'PERSEN07' => '' . $rs->Fields['PERSEN07'] . '',
                'PERSEN08' => '' . $rs->Fields['PERSEN08'] . '',
                'PERSEN09' => '' . $rs->Fields['PERSEN09'] . '',
                'PERSEN10' => '' . $rs->Fields['PERSEN10'] . '',
                'PERSEN11' => '' . $rs->Fields['PERSEN11'] . '',
                'PERSEN12' => '' . $rs->Fields['PERSEN12'] . '',
                'CHK01' => '' . $rs->Fields['CHK01'] . '',
                'CHK02' => '' . $rs->Fields['CHK02'] . '',
                'CHK03' => '' . $rs->Fields['CHK03'] . '',
                'CHK04' => '' . $rs->Fields['CHK04'] . '',
                'CHK05' => '' . $rs->Fields['CHK05'] . '',
                'CHK06' => '' . $rs->Fields['CHK06'] . '',
                'CHK07' => '' . $rs->Fields['CHK07'] . '',
                'CHK08' => '' . $rs->Fields['CHK08'] . '',
                'CHK09' => '' . $rs->Fields['CHK09'] . '',
                'CHK10' => '' . $rs->Fields['CHK10'] . '',
                'CHK11' => '' . $rs->Fields['CHK11'] . '',
                'CHK12' => '' . $rs->Fields['CHK12'] . '',
                'CHKJMLTRK' => '' . $rs->Fields['CHKJMLTRK'] . '',
                'CHKPERSEN' => '' . $rs->Fields['CHKPERSEN'] . '',
                'CHKRATA2' => '' . $rs->Fields['CHKRATA2'] . '',
                'CHKRATA2GJ' => '' . $rs->Fields['CHKRATA2GJ'] . '',
                'KDLOKASI' => '' . $rs->Fields['KDLOKASI'] . '',
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DTrktrm;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->KDFUNGSI = $r['KDFUNGSI'];
            $model->KDSFUNG = $r['KDSFUNG'];
            $model->KDPROGRAM = $r['KDPROGRAM'];
            $model->KDGIAT = $r['KDGIAT'];
            $model->RPHPAGU = $r['RPHPAGU'];
            $model->KDTRKTRM = $r['KDTRKTRM'];
            $model->JNSBELANJA = $r['JNSBELANJA'];
            $model->JML01 = $r['JML01'];
            $model->JML02 = $r['JML02'];
            $model->JML03 = $r['JML03'];
            $model->JML04 = $r['JML04'];
            $model->JML05 = $r['JML05'];
            $model->JML06 = $r['JML06'];
            $model->JML07 = $r['JML07'];
            $model->JML08 = $r['JML08'];
            $model->JML09 = $r['JML09'];
            $model->JML10 = $r['JML10'];
            $model->JML11 = $r['JML11'];
            $model->JML12 = $r['JML12'];
            $model->CHK01 = $r['CHK01'];
            $model->CHK02 = $r['CHK02'];
            $model->CHK03 = $r['CHK03'];
            $model->CHK04 = $r['CHK04'];
            $model->CHK05 = $r['CHK05'];
            $model->CHK06 = $r['CHK06'];
            $model->CHK07 = $r['CHK07'];
            $model->CHK08 = $r['CHK08'];
            $model->CHK09 = $r['CHK09'];
            $model->CHK10 = $r['CHK10'];
            $model->CHK11 = $r['CHK11'];
            $model->CHK12 = $r['CHK12'];
            $model->CHKJMLTRK = $r['CHKJMLTRK'];
            $model->CHKPERSEN = $r['CHKPERSEN'];
            $model->CHKRATA2 = $r['CHKRATA2'];
            $model->CHKRATA2GJ = $r['CHKRATA2GJ'];
            $model->KDLOKASI = $r['KDLOKASI'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function US($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'NODIPA' => '' . $rs->Fields['NODIPA'] . '',
                'NOMOR' => '' . $rs->Fields['NOMOR'] . '',
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                'SIFAT' => '' . $rs->Fields['SIFAT'] . '',
                'TGL' => '' . $rs->Fields['TGL'] . '',
                'LAMPIRAN' => '' . $rs->Fields['LAMPIRAN'] . '',
                'HAL' => '' . $rs->Fields['HAL'] . '',
                'YTH1' => '' . $rs->Fields['YTH1'] . '',
                'YTH2' => '' . $rs->Fields['YTH2'] . '',
                'YTH3' => '' . $rs->Fields['YTH3'] . '',
                'DASAR1' => '' . $rs->Fields['DASAR1'] . '',
                'DASAR2' => '' . $rs->Fields['DASAR2'] . '',
                'DASAR3' => '' . $rs->Fields['DASAR3'] . '',
                'DASAR4' => '' . $rs->Fields['DASAR4'] . '',
                'DASAR5' => '' . $rs->Fields['DASAR5'] . '',
                'DASAR6' => '' . $rs->Fields['DASAR6'] . '',
                'DASAR7' => '' . $rs->Fields['DASAR7'] . '',
                'DASAR8' => '' . $rs->Fields['DASAR8'] . '',
                'DASAR9' => '' . $rs->Fields['DASAR9'] . '',
                'DASAR10' => '' . $rs->Fields['DASAR10'] . '',
                'JELAS1' => '' . $rs->Fields['JELAS1'] . '',
                'JELAS2' => '' . $rs->Fields['JELAS2'] . '',
                'JELAS3' => '' . $rs->Fields['JELAS3'] . '',
                'JELAS4' => '' . $rs->Fields['JELAS4'] . '',
                'JELAS5' => '' . $rs->Fields['JELAS5'] . '',
                'JELAS6' => '' . $rs->Fields['JELAS6'] . '',
                'JELAS7' => '' . $rs->Fields['JELAS7'] . '',
                'JELAS8' => '' . $rs->Fields['JELAS8'] . '',
                'JELAS9' => '' . $rs->Fields['JELAS9'] . '',
                'JELAS10' => '' . $rs->Fields['JELAS10'] . '',
                'NIP' => '' . $rs->Fields['NIP'] . '',
                'TEMBUSAN1' => '' . $rs->Fields['TEMBUSAN1'] . '',
                'TEMBUSAN2' => '' . $rs->Fields['TEMBUSAN2'] . '',
                'TEMBUSAN3' => '' . $rs->Fields['TEMBUSAN3'] . '',
                'TEMBUSAN4' => '' . $rs->Fields['TEMBUSAN4'] . '',
                'TEMBUSAN5' => '' . $rs->Fields['TEMBUSAN5'] . '',
                'TEMBUSAN6' => '' . $rs->Fields['TEMBUSAN6'] . '',
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DUsulsah;
            $model->NODIPA = $r['NODIPA'];
            $model->NOMOR = $r['NOMOR'];
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->SIFAT = $r['SIFAT'];
            $model->TGL = $r['TGL'];
            $model->HAL = $r['HAL'];
            $model->YTH1 = $r['YTH1'];
            $model->YTH2 = $r['YTH2'];
            $model->YTH3 = $r['YTH3'];
            $model->DASAR1 = $r['DASAR1'];
            $model->DASAR2 = $r['DASAR2'];
            $model->DASAR3 = $r['DASAR3'];
            $model->DASAR4 = $r['DASAR4'];
            $model->DASAR5 = $r['DASAR5'];
            $model->DASAR6 = $r['DASAR6'];
            $model->DASAR7 = $r['DASAR7'];
            $model->DASAR8 = $r['DASAR8'];
            $model->DASAR9 = $r['DASAR9'];
            $model->DASAR10 = $r['DASAR10'];
            $model->JELAS1 = $r['JELAS1'];
            $model->JELAS2 = $r['JELAS2'];
            $model->JELAS3 = $r['JELAS3'];
            $model->JELAS4 = $r['JELAS4'];
            $model->JELAS5 = $r['JELAS5'];
            $model->JELAS6 = $r['JELAS6'];
            $model->JELAS7 = $r['JELAS7'];
            $model->JELAS8 = $r['JELAS8'];
            $model->JELAS9 = $r['JELAS9'];
            $model->JELAS10 = $r['JELAS10'];
            $model->NIP = $r['NIP'];
            $model->TEMBUSAN1 = $r['TEMBUSAN1'];
            $model->TEMBUSAN2 = $r['TEMBUSAN2'];
            $model->TEMBUSAN3 = $r['TEMBUSAN3'];
            $model->TEMBUSAN4 = $r['TEMBUSAN4'];
            $model->TEMBUSAN5 = $r['TEMBUSAN5'];
            $model->TEMBUSAN6 = $r['TEMBUSAN6'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

    function VL($fileName, $conn, $upload_path) {
        $query = "SELECT * FROM " . $fileName;
        $rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
        $data = array();
        while (!$rs->EOF) {
            array_push($data, array(
                'THANG' => '' . $rs->Fields['THANG'] . '',
                'KDJENDOK' => '' . $rs->Fields['KDJENDOK'] . '',
                'KDSATKER' => '' . $rs->Fields['KDSATKER'] . '',
                'KDDEPT' => '' . $rs->Fields['KDDEPT'] . '',
                'KDUNIT' => '' . $rs->Fields['KDUNIT'] . '',
                'KDDEKON' => '' . $rs->Fields['KDDEKON'] . '',
                'REGISTER' => '' . $rs->Fields['REGISTER'] . '',
                'KDVALAS' => '' . $rs->Fields['KDVALAS'] . '',
                'NILAIVALAS' => '' . $rs->Fields['NILAIVALAS'] . '',
                'EKUIUSD' => '' . $rs->Fields['EKUIUSD'] . '',
                'EKUIRPH' => '' . $rs->Fields['EKUIRPH'] . '',
                    )
            );
            $rs->MoveNext();
        }

        foreach ($data as $val => $r) {
            $model = new DValas;
            $model->THANG = $r['THANG'];
            $model->KDJENDOK = $r['KDJENDOK'];
            $model->KDSATKER = $r['KDSATKER'];
            $model->KDDEPT = $r['KDDEPT'];
            $model->KDUNIT = $r['KDUNIT'];
            $model->KDDEKON = $r['KDDEKON'];
            $model->REGISTER = $r['REGISTER'];
            $model->KDVALAS = $r['KDVALAS'];
            $model->NILAIVALAS = $r['NILAIVALAS'];
            $model->EKUIUSD = $r['EKUIUSD'];
            $model->EKUIRPH = $r['EKUIRPH'];
            $model->save();
        }
        $conn->Close();
        unlink($upload_path . $fileName);
    }

}

?>
